<script type="text/javascript">
  angular.module('djangular-demo', ['djng.forms']).config(function($httpProvider) {
    $httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
    $httpProvider.defaults.headers.common['X-CSRFToken'] = '{{ csrf_token }}';
  });
</script>

<form name="{{ form.form_name }}" djng-endpoint="." ng-model-options="{allowInvalid: true}" novalidate>
  {{ form.as_div }}
  <button ng-click="do(update()).then(redirectTo()).catch(scrollToRejected())" type="button">
    Forced Submission <i class="some-icon"></i>
  </button>
  <button ng-click="do(update()).then(redirectTo())" ng-disabled="isDisabled()" type="button">
    Validated Submission <i class="some-icon"></i>
  </button>
  <button ng-click="do(spinner()).then(update({delay: true})).then(showOK()).then(delay(500)).then(redirectTo()).catch(showFail()).then(delay(1500)).finally(restore())" ng-disabled="isDisabled()" type="button">
    Delayed Submission <i class="some-icon"></i>
  </button>
  <button ng-click="do(fetch())" type="button">
    Fetch Defaults <i class="some-icon"></i>
  </button>
</form>
